#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<stdlib.h>

int main(){
    int fd1 = open("dup_test.txt", O_RDWR | O_CREAT, 0666);
    int fd2 = dup(fd1);

    write(fd1, "hello world\n", 11);
    write(fd2, "HELLO WORLD\n", 11);

    close(fd1);
    close(fd2);
}